using System;

namespace Sedna.Core.Controller.Configurations
{
	/// <summary>
	/// Summary description for DropDownListConfiguration.
	/// </summary>
    public class DropDownListConfiguration : DataListConfiguration, IDropDownListConfiguration
	{
		private bool autoPostBack=false;		
	    
        private bool addEmptyItem;
        private string emptyItemText = "";
        private string emptyItemTextKey;
        private string emptyItemValue = "";

        private IDataTranslator selectedValueDataTranslator;

        #region Properties

        public IDataTranslator SelectedValueDataTranslator
	    {
	        get { return selectedValueDataTranslator; }
	        set { selectedValueDataTranslator = value; }
	    }

        public bool AutoPostBack
		{
			get { return autoPostBack; }
			set { autoPostBack = value; }
		}		

	    public bool AddEmptyItem
        {
            get { return addEmptyItem; }
            set { addEmptyItem = value; }
        }

	    public string EmptyItemText
	    {
	        get { return emptyItemText; }
	        set { emptyItemText = value; }
	    }

	    public string EmptyItemTextKey
	    {
	        get { return emptyItemTextKey; }
	        set { emptyItemTextKey = value; }
	    }

	    public string EmptyItemValue
	    {
	        get { return emptyItemValue; }
	        set { emptyItemValue = value; }
        }

	    #endregion
	    
        public override IConfiguration CreateFromTemplate()
        {
            DropDownListConfiguration that = (DropDownListConfiguration)base.CreateFromTemplate();
            that.SelectedIndexBindPath = SelectedIndexBindPath;
            that.SelectedIndexUnbindPath = SelectedIndexUnbindPath;
            that.SelectedTextUnbindPath = SelectedTextUnbindPath;
            that.SelectedValueBindPath = SelectedValueBindPath;
            that.SelectedValueUnbindPath = SelectedValueUnbindPath;
            that.DataSourceBindPath = DataSourceBindPath;
            that.DataSourceUnbindPath = DataSourceUnbindPath;
            that.DataTextFieldBindPath = DataTextFieldBindPath;
            that.DataTextFieldUnbindPath = DataTextFieldUnbindPath;
            that.DataValueFieldBindPath = DataValueFieldBindPath;
            that.DataValueFieldUnbindPath = DataValueFieldUnbindPath;
            that.DataTextField = DataTextField;
            that.DataValueField = DataValueField;
            that.addEmptyItem = addEmptyItem;
            that.emptyItemText = emptyItemText;
            that.emptyItemTextKey = emptyItemTextKey;
            that.emptyItemValue = emptyItemValue;
            that.Controller = Controller;
            that.selectedValueDataTranslator = selectedValueDataTranslator;
            return that;
        }
	}

}
